<template>
	<view class="container">
		<TopBtn :title="'续方详情'"></TopBtn>
		<view class="info">
			<!-- <view class="currency_card jjBox" v-if="data.status==3">
				<view class="jjtitle flex-center">
					<image src="@/static/ConsultationRoom/del.png" mode="aspectFill"></image> 拒绝原因
				</view>
				<view class="">
					{{data.rejectReason}}
				</view>
			</view> -->
			<view class="patientBox">
				<view class="presStatusName flex-center-center" :id="data.preStatus==1?'presStatusName':''">
					{{data.presStatusName}}
				</view>
				<view class="currency_card" v-if="data.status!=1">
					<view class="Card">
						<image :src="data.patientAvatar" mode=""></image>
						<view class="">
							<view class="doctorName">
								{{data.doctorName}} <text>{{data.titleName}}</text><text>{{data.departName}}</text>
							</view>
							<view class="doctorHospital">
								<text>{{data.hospitalLevelName}}</text> {{data.hospitalName}}
							</view>
						</view>
					</view>
				</view>
				<view class="patientInfo" v-if="data.preStatus==2">
					<view class="title">
						审方状态
					</view>
					<view class="info">
						{{data.preRefuseReason}}
					</view>
				</view>
				<view class="patientInfo" v-if="data.status==4">
					<view class="title">
						拒绝原因
					</view>
					<view class="info">
						{{data.rejectReason}}
					</view>
				</view>
			</view>

			<view class="patientBox">

				<patientCard :data="data"></patientCard>
				<view class="patientInfo">
					<view class="title">
						病情描述
					</view>
					<view class="info">
						{{data.diseaseDescribe}}
					</view>
				</view>
			</view>
			<view class="currency_card">
				<view class="currency_title ">
					病情资料
				</view>
				<view class="flex-center-center">
					<!-- <DiseaseCondition v-if="data.consultationFormRespVO" :data="data.consultationFormRespVO"></DiseaseCondition> -->
					<view class="currency_info DiseaseConditionBox">
						<view class="Card_Disease_condition" v-if="data.attachment">
							<view class="title">
								<text>·</text> 处方照片
							</view>
							<view class="text">
								<!-- attachment -->
								<image :src="data.attachment" mode=""></image>
							</view>
						</view>
						<view class="Card_Disease_condition" v-if="data.drugStateName">
							<view class="title">
								<text>·</text> 药态
							</view>
							<view class="text">
								{{data.drugStateName}}
							</view>
						</view>
						<view class="Card_Disease_condition" v-if="data.specialStageName">
							<view class="title">
								<text>·</text> 是否处于特殊阶段
							</view>
							<view class="text">
								{{data.specialStageName}}
							</view>
						</view>
						<view class="Card_Disease_condition" v-if="data.explanation">
							<view class="title">
								<text>·</text> 补充说明
							</view>
							<view class="text">
								{{data.explanation}}
							</view>
						</view>
					</view>
				</view>
			</view>

		</view>
		<view class="kong">

		</view>
		<view class="btnBoxTow" v-if="data.status==1">
			<view class="cancel" @click="openPup()">
				拒绝开方
			</view>
			<view class="confirm" @click="goInfo('pages/ConsultationRoom/Prescription/Prescription', data.id)">
				开具处方
			</view>
		</view>
		<uni-popup ref="popup" type="bottom">
			<view class="pupbox">
				<view class="title">
					<view class="close" @click="closePup()">
						取消
					</view>
					拒绝原因
					<view class="add" @click="Submit()">
						确认
					</view>
				</view>
				<view class="">
					<textArea v-model="rejectReason" :inputNane="rejectReason" :maxNum="50"></textArea>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import {
		getOnlinePreFromDetail,
		refuseOnlinePreForm
	} from '@/api/ConsultationRoom'
	export default {
		data() {
			return {
				data: {},
				id: "",
				rejectReason: ""

			};
		},
		onShow() {
			var that = this
			uni.$once('show', function(data) {
				if (data) {
					that.getOnlinePreFromDetail(that.id)
				}
			})
		},
		onUnload() {
					uni.$off()
				},
		onLoad(e) {
			this.id = e.id
			this.getOnlinePreFromDetail(e.id)
		},
		methods: {
			closePup() {
				this.$refs.popup.close()
				// this.data = {}
			},
			Submit() {
				if (!this.rejectReason) {
					uni.showToast({
						title: '请填写拒绝原因',
						duration: 2000,
						icon: 'none',
					})
					return
				}
				this.refuseOnlinePreForm(4)
				this.rejectReason = ""
				this.getOnlinePreFromDetail(this.id)
				this.closePup()
			},
			openPup(e, id) {
				this.$refs.popup.open('bottom')
				this.rejectReason = ""
			},
			refuseOnlinePreForm(e) {
				refuseOnlinePreForm({
					id: this.id,
					status: e,
					rejectReason: this.rejectReason
				}).then(res => {
					uni.showToast({
						title: '操作成功',
						duration: 2000,
						icon: 'none',
					})
					this.getOnlinePreFromDetail(this.id)
				})
			},
			getOnlinePreFromDetail(e) {
				getOnlinePreFromDetail({
					id: e
				}).then(res => {
					this.data = res.data
				})
			},
			goInfo(e, id) {
				var updata = 0

				if (id) {
					uni.navigateTo({
						url: `/${e}?id=${id}&updata=${updata}&type=2`,
					})
				} else {
					uni.navigateTo({
						url: `/${e}`,
					})
				}
			},

		}
	}
</script>

<style lang="less">
	.patientBox {
		width: 690rpx;
		min-height: 105rpx;
		background: #FFFFFF;
		border-radius: 30rpx;
		position: relative;

		.presStatusName {
			position: absolute;
			z-index: 1;
			top: 0;
			right: 0;
			width: 113rpx;
			height: 55rpx;
			background: rgba(230, 0, 18, 0.16);
			border-radius: 0 30rpx 0 30rpx;
			font-weight: 500;
			font-size: 26rpx;
			color: #E60012;
		}

		#presStatusName {
			background: rgba(59, 108, 254, 0.16);
			color: #3E6EFE;
		}

		.patientInfo {
			padding: 20rpx;
			box-sizing: border-box;
		}

		.title {
			font-weight: bold;
			font-size: 30rpx;
			color: #333333;
			padding: 30rpx 0;
			border-top: 1px solid #EEEEEE;
		}

		.info {
			min-height: 104rpx;
			background: #FAFAFA;
			border-radius: 10rpx;
			padding: 10rpx 20rpx;
			box-sizing: border-box;
		}
	}

	.DiseaseConditionBox {
		width: 100%;
		margin-top: 20rpx !important;
		padding-top: 30rpx;
		background: #FAFAFA;
		border-radius: 10rpx;

		.Card_Disease_condition {
			font-size: 28rpx;
			margin-bottom: 15rpx;
			color: #333333;

			.title {
				color: #999999;
				margin-bottom: 12rpx;

				text {
					width: 40rpx;
					display: inline-block;
					text-align: center;
				}
			}

			.text {
				margin-left: 40rpx;

				image {
					width: 113rpx;
					height: 113rpx;
					border-radius: 5rpx;
					margin-right: 25rpx;
				}
			}

		}
	}

	.jjBox {
		font-weight: 500;
		font-size: 28rpx;
		color: #333333;

		.jjtitle {
			margin-bottom: 15rpx;
			font-weight: bold;
			font-size: 32rpx;
			color: #333333;

			image {
				width: 33rpx;
				height: 33rpx;
			}
		}
	}

	.Card {
		display: flex;
		align-items: center;
		padding: 10rpx 20rpx;

		.doctorHospital {
			margin-top: 9rpx;

			text {
				display: inline-block;
				background: #DEF7ED;
				padding: 5rpx 10rpx;
				border-radius: 10rpx;
				color: #23CC88;
				margin-right: 10rpx;
			}

			font-size: 24rpx;
			color: #666666;
		}

		.doctorName {
			font-weight: bold;
			font-size: 32rpx;
			color: #333333;

			text {
				margin-left: 19rpx;
				font-size: 24rpx;
				color: #333;
				font-weight: normal;
			}

		}

		.IdCard {
			margin-top: 9rpx;

			text {
				display: inline-block;
				background: #DEF7ED;
				padding: 5rpx 10rpx;
				border-radius: 10rpx;
				color: #23CC88;
				margin-right: 10rpx;
			}

			font-size: 24rpx;
			color: #666666;
		}

		image {
			width: 90rpx;
			height: 90rpx;
			margin-right: 33rpx;
			border-radius: 50%;
		}
	}

	.state2 {
		width: 86rpx;
		height: 33rpx;
		border-radius: 10rpx;
		border: 1px solid #3E6EFE;
		font-weight: 500;
		font-size: 22rpx;
		margin-left: 15rpx;
		color: #3E6EFE !important;
	}

	.pupbox {
		width: 750rpx;
		height: 522rpx;
		background: #ffffff;
		border-radius: 50rpx 50rpx 0rpx 0rpx;
		padding: 30rpx 50rpx;
		box-sizing: border-box;
		background-size: 100% 100%;

		.title {
			font-size: 36rpx;
			font-weight: bold;
			color: #333333;
			position: relative;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.add {
				font-weight: 500;
				font-size: 28rpx;
				color: #3E6EFE
			}

			.close {
				font-weight: 500;
				font-size: 28rpx;
				color: #999999;
			}

		}

		.messageList {
			margin-top: 1em;

			margin-top: 1em;

			.scroll-view_H {
				white-space: nowrap;
				width: 100%;
			}

			.messageinfo {
				display: inline-block;
				width: 287rpx;
				height: 220rpx;
				border: 2px solid #eeeeee;
				border-radius: 15rpx;
				margin-right: 25rpx;
				padding: 20rpx;
				box-sizing: border-box;
				font-size: 26rpx;
				font-weight: 500;
				color: #999999;
				vertical-align: top;
			}

			.text {
				height: 100%;
				display: flex;
				align-items: center;
				white-space: wrap;
				white-space: pre-wrap;
				/* css-3 */
				white-space: -moz-pre-wrap;
				/* Mozilla, since 1999 */
				white-space: -pre-wrap;
				/* Opera 4-6 */
				white-space: -o-pre-wrap;
				/* Opera 7 */
				word-wrap: break-word;
				/* Internet Explorer 5.5+ */
			}

			.act {
				border: 4rpx solid #aa75fa;
				color: #7e67fd;
			}
		}

		// 多行文本输入框
		/deep/.uni-easyinput__content {
			border: none;
		}

		// 多行文本输入框
		/deep/.is-textarea {
			background-color: #f9f9f9 !important;
			margin: 23rpx 0 40rpx;

		}

		/deep/.is-input-border {
			border-radius: 20rpx;
		}

		/deep/.uni-easyinput__placeholder-class {
			font-size: 28rpx;
		}
	}

	.info {
		padding: 30rpx;

		.currency_card {
			position: relative;

			.state {
				position: absolute;
				right: 0;
				top: 0;
				padding: 0 5rpx;
				min-width: 100rpx;
				height: 50rpx;
				background: #F9FBFE;
				font-size: 28rpx;
				color: #3E6EFE;
				text-align: center;
				line-height: 50rpx;
				border-radius: 0 21rpx;
			}
		}

		&>view {
			margin-bottom: 27rpx;
		}

		.currency_info {
			margin-top: 21rpx;

			&:last-child {
				margin-top: 0rpx;
			}


			.Card_row {
				display: flex;
				font-weight: 500;
				font-size: 28rpx;
				color: #333;
				align-items: center;
				min-height: 50rpx;

				.title {
					width: 150rpx;
					color: #999;
				}
			}

			.alignItems {
				align-items: self-start;
			}
		}

	}
</style>